package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.gui.JImageEditor;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.DataLogicSales;
import com.openbravo.pos.sales.TaxesLogic;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.Date;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

public class ProductsEditor extends JPanel
  implements EditorRecord
{
  private SentenceList m_sentcat;
  private ComboBoxValModel m_CategoryModel;
  private SentenceList taxcatsent;
  private ComboBoxValModel taxcatmodel;
  private SentenceList attsent;
  private ComboBoxValModel attmodel;
  private SentenceList taxsent;
  private TaxesLogic taxeslogic;
  private ComboBoxValModel m_CodetypeModel;
  private Object m_id;
  private Object pricesell;
  private boolean priceselllock = false;
  private boolean reportlock = false;
  private JLabel jLabel1;
  private JLabel jLabel10;
  private JLabel jLabel11;
  private JLabel jLabel12;
  private JLabel jLabel13;
  private JLabel jLabel16;
  private JLabel jLabel18;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JLabel jLabel5;
  private JLabel jLabel6;
  private JLabel jLabel7;
  private JLabel jLabel8;
  private JLabel jLabel9;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JPanel jPanel3;
  private JScrollPane jScrollPane1;
  private JTabbedPane jTabbedPane1;
  private JComboBox m_jAtt;
  private JTextField m_jCatalogOrder;
  private JComboBox m_jCategory;
  private JTextField m_jCode;
  private JComboBox m_jCodetype;
  private JCheckBox m_jComment;
  private JImageEditor m_jImage;
  private JCheckBox m_jInCatalog;
  private JTextField m_jName;
  private JTextField m_jPriceBuy;
  private JTextField m_jPriceSell;
  private JTextField m_jPriceSellTax;
  private JTextField m_jRef;
  private JCheckBox m_jScale;
  private JComboBox m_jTax;
  private JLabel m_jTitle;
  private JTextField m_jmargin;
  private JTextField m_jstockcost;
  private JTextField m_jstockvolume;
  private JTextArea txtAttributes;

  public ProductsEditor(DataLogicSales paramDataLogicSales, DirtyManager paramDirtyManager)
  {
    initComponents();
    this.taxsent = paramDataLogicSales.getTaxList();
    this.m_sentcat = paramDataLogicSales.getCategoriesList();
    this.m_CategoryModel = new ComboBoxValModel();
    this.taxcatsent = paramDataLogicSales.getTaxCategoriesList();
    this.taxcatmodel = new ComboBoxValModel();
    this.attsent = paramDataLogicSales.getAttributeSetList();
    this.attmodel = new ComboBoxValModel();
    this.m_CodetypeModel = new ComboBoxValModel();
    this.m_CodetypeModel.add(null);
    this.m_CodetypeModel.add(CodeType.EAN13);
    this.m_CodetypeModel.add(CodeType.CODE128);
    this.m_jCodetype.setModel(this.m_CodetypeModel);
    this.m_jCodetype.setVisible(false);
    this.m_jRef.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jCode.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jName.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jComment.addActionListener(paramDirtyManager);
    this.m_jScale.addActionListener(paramDirtyManager);
    this.m_jCategory.addActionListener(paramDirtyManager);
    this.m_jTax.addActionListener(paramDirtyManager);
    this.m_jAtt.addActionListener(paramDirtyManager);
    this.m_jPriceBuy.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jPriceSell.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jImage.addPropertyChangeListener("image", paramDirtyManager);
    this.m_jstockcost.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jstockvolume.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jInCatalog.addActionListener(paramDirtyManager);
    this.m_jCatalogOrder.getDocument().addDocumentListener(paramDirtyManager);
    this.txtAttributes.getDocument().addDocumentListener(paramDirtyManager);
    FieldsManager localFieldsManager = new FieldsManager( );
    this.m_jPriceBuy.getDocument().addDocumentListener(localFieldsManager);
    this.m_jPriceSell.getDocument().addDocumentListener(new PriceSellManager( ));
    this.m_jTax.addActionListener(localFieldsManager);
    this.m_jPriceSellTax.getDocument().addDocumentListener(new PriceTaxManager( ));
    this.m_jmargin.getDocument().addDocumentListener(new MarginManager( ));
    writeValueEOF();
  }

  public void activate()
    throws BasicException
  {
    this.taxeslogic = new TaxesLogic(this.taxsent.list());
    this.m_CategoryModel = new ComboBoxValModel(this.m_sentcat.list());
    this.m_jCategory.setModel(this.m_CategoryModel);
    this.taxcatmodel = new ComboBoxValModel(this.taxcatsent.list());
    this.m_jTax.setModel(this.taxcatmodel);
    this.attmodel = new ComboBoxValModel(this.attsent.list());
    this.attmodel.add(0, null);
    this.m_jAtt.setModel(this.attmodel);
  }

  public void refresh()
  {
  }

  public void writeValueEOF()
  {
    this.reportlock = true;
    this.m_jTitle.setText(AppLocal.getIntString("label.recordeof"));
    this.m_id = null;
    this.m_jRef.setText(null);
    this.m_jCode.setText(null);
    this.m_jName.setText(null);
    this.m_jComment.setSelected(false);
    this.m_jScale.setSelected(false);
    this.m_CategoryModel.setSelectedKey(null);
    this.taxcatmodel.setSelectedKey(null);
    this.attmodel.setSelectedKey(null);
    this.m_jPriceBuy.setText(null);
    setPriceSell(null);
    this.m_jImage.setImage(null);
    this.m_jstockcost.setText(null);
    this.m_jstockvolume.setText(null);
    this.m_jInCatalog.setSelected(false);
    this.m_jCatalogOrder.setText(null);
    this.txtAttributes.setText(null);
    this.reportlock = false;
    this.m_jRef.setEnabled(false);
    this.m_jCode.setEnabled(false);
    this.m_jName.setEnabled(false);
    this.m_jComment.setEnabled(false);
    this.m_jScale.setEnabled(false);
    this.m_jCategory.setEnabled(false);
    this.m_jTax.setEnabled(false);
    this.m_jAtt.setEnabled(false);
    this.m_jPriceBuy.setEnabled(false);
    this.m_jPriceSell.setEnabled(false);
    this.m_jPriceSellTax.setEnabled(false);
    this.m_jmargin.setEnabled(false);
    this.m_jImage.setEnabled(false);
    this.m_jstockcost.setEnabled(false);
    this.m_jstockvolume.setEnabled(false);
    this.m_jInCatalog.setEnabled(false);
    this.m_jCatalogOrder.setEnabled(false);
    this.txtAttributes.setEnabled(false);
    calculateMargin();
    calculatePriceSellTax();
  }

  public void writeValueInsert()
  {
    this.reportlock = true;
    this.m_jTitle.setText(AppLocal.getIntString("label.recordnew"));
    this.m_id = UUID.randomUUID().toString();
    this.m_jRef.setText(null);
    this.m_jCode.setText(null);
    this.m_jName.setText(null);
    this.m_jComment.setSelected(false);
    this.m_jScale.setSelected(false);
    this.m_CategoryModel.setSelectedKey(null);
    this.taxcatmodel.setSelectedKey(null);
    this.attmodel.setSelectedKey(null);
    this.m_jPriceBuy.setText(null);
    setPriceSell(null);
    this.m_jImage.setImage(null);
    this.m_jstockcost.setText(null);
    this.m_jstockvolume.setText(null);
    this.m_jInCatalog.setSelected(true);
    this.m_jCatalogOrder.setText(null);
    this.txtAttributes.setText(null);
    this.reportlock = false;
    this.m_jRef.setEnabled(true);
    this.m_jCode.setEnabled(true);
    this.m_jName.setEnabled(true);
    this.m_jComment.setEnabled(true);
    this.m_jScale.setEnabled(true);
    this.m_jCategory.setEnabled(true);
    this.m_jTax.setEnabled(true);
    this.m_jAtt.setEnabled(true);
    this.m_jPriceBuy.setEnabled(true);
    this.m_jPriceSell.setEnabled(true);
    this.m_jPriceSellTax.setEnabled(true);
    this.m_jmargin.setEnabled(true);
    this.m_jImage.setEnabled(true);
    this.m_jstockcost.setEnabled(true);
    this.m_jstockvolume.setEnabled(true);
    this.m_jInCatalog.setEnabled(true);
    this.m_jCatalogOrder.setEnabled(false);
    this.txtAttributes.setEnabled(true);
    calculateMargin();
    calculatePriceSellTax();
  }

  public void writeValueDelete(Object paramObject)
  {
    this.reportlock = true;
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.m_jTitle.setText(Formats.STRING.formatValue(arrayOfObject[1]) + " - " + Formats.STRING.formatValue(arrayOfObject[3]) + " " + AppLocal.getIntString("label.recorddeleted"));
    this.m_id = arrayOfObject[0];
    this.m_jRef.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jCode.setText(Formats.STRING.formatValue(arrayOfObject[2]));
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[3]));
    this.m_jComment.setSelected(((Boolean)arrayOfObject[4]).booleanValue());
    this.m_jScale.setSelected(((Boolean)arrayOfObject[5]).booleanValue());
    this.m_jPriceBuy.setText(Formats.CURRENCY.formatValue(arrayOfObject[6]));
    setPriceSell(arrayOfObject[7]);
    this.m_CategoryModel.setSelectedKey(arrayOfObject[8]);
    this.taxcatmodel.setSelectedKey(arrayOfObject[9]);
    this.attmodel.setSelectedKey(arrayOfObject[10]);
    this.m_jImage.setImage((BufferedImage)arrayOfObject[11]);
    this.m_jstockcost.setText(Formats.CURRENCY.formatValue(arrayOfObject[12]));
    this.m_jstockvolume.setText(Formats.DOUBLE.formatValue(arrayOfObject[13]));
    this.m_jInCatalog.setSelected(((Boolean)arrayOfObject[14]).booleanValue());
    this.m_jCatalogOrder.setText(Formats.INT.formatValue(arrayOfObject[15]));
    this.txtAttributes.setText(Formats.BYTEA.formatValue(arrayOfObject[16]));
    this.txtAttributes.setCaretPosition(0);
    this.reportlock = false;
    this.m_jRef.setEnabled(false);
    this.m_jCode.setEnabled(false);
    this.m_jName.setEnabled(false);
    this.m_jComment.setEnabled(false);
    this.m_jScale.setEnabled(false);
    this.m_jCategory.setEnabled(false);
    this.m_jTax.setEnabled(false);
    this.m_jAtt.setEnabled(false);
    this.m_jPriceBuy.setEnabled(false);
    this.m_jPriceSell.setEnabled(false);
    this.m_jPriceSellTax.setEnabled(false);
    this.m_jmargin.setEnabled(false);
    this.m_jImage.setEnabled(false);
    this.m_jstockcost.setEnabled(false);
    this.m_jstockvolume.setEnabled(false);
    this.m_jInCatalog.setEnabled(false);
    this.m_jCatalogOrder.setEnabled(false);
    this.txtAttributes.setEnabled(false);
    calculateMargin();
    calculatePriceSellTax();
  }

  public void writeValueEdit(Object paramObject)
  {
    this.reportlock = true;
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.m_jTitle.setText(Formats.STRING.formatValue(arrayOfObject[1]) + " - " + Formats.STRING.formatValue(arrayOfObject[3]));
    this.m_id = arrayOfObject[0];
    this.m_jRef.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jCode.setText(Formats.STRING.formatValue(arrayOfObject[2]));
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[3]));
    this.m_jComment.setSelected(((Boolean)arrayOfObject[4]).booleanValue());
    this.m_jScale.setSelected(((Boolean)arrayOfObject[5]).booleanValue());
    this.m_jPriceBuy.setText(Formats.CURRENCY.formatValue(arrayOfObject[6]));
    setPriceSell(arrayOfObject[7]);
    this.m_CategoryModel.setSelectedKey(arrayOfObject[8]);
    this.taxcatmodel.setSelectedKey(arrayOfObject[9]);
    this.attmodel.setSelectedKey(arrayOfObject[10]);
    this.m_jImage.setImage((BufferedImage)arrayOfObject[11]);
    this.m_jstockcost.setText(Formats.CURRENCY.formatValue(arrayOfObject[12]));
    this.m_jstockvolume.setText(Formats.DOUBLE.formatValue(arrayOfObject[13]));
    this.m_jInCatalog.setSelected(((Boolean)arrayOfObject[14]).booleanValue());
    this.m_jCatalogOrder.setText(Formats.INT.formatValue(arrayOfObject[15]));
    this.txtAttributes.setText(Formats.BYTEA.formatValue(arrayOfObject[16]));
    this.txtAttributes.setCaretPosition(0);
    this.reportlock = false;
    this.m_jRef.setEnabled(true);
    this.m_jCode.setEnabled(true);
    this.m_jName.setEnabled(true);
    this.m_jComment.setEnabled(true);
    this.m_jScale.setEnabled(true);
    this.m_jCategory.setEnabled(true);
    this.m_jTax.setEnabled(true);
    this.m_jAtt.setEnabled(true);
    this.m_jPriceBuy.setEnabled(true);
    this.m_jPriceSell.setEnabled(true);
    this.m_jPriceSellTax.setEnabled(true);
    this.m_jmargin.setEnabled(true);
    this.m_jImage.setEnabled(true);
    this.m_jstockcost.setEnabled(true);
    this.m_jstockvolume.setEnabled(true);
    this.m_jInCatalog.setEnabled(true);
    this.m_jCatalogOrder.setEnabled(this.m_jInCatalog.isSelected());
    this.txtAttributes.setEnabled(true);
    calculateMargin();
    calculatePriceSellTax();
  }

  public Object createValue()
    throws BasicException
  {
    Object[] arrayOfObject = new Object[17];
    arrayOfObject[0] = this.m_id;
    arrayOfObject[1] = this.m_jRef.getText();
    arrayOfObject[2] = this.m_jCode.getText();
    arrayOfObject[3] = this.m_jName.getText();
    arrayOfObject[4] = Boolean.valueOf(this.m_jComment.isSelected());
    arrayOfObject[5] = Boolean.valueOf(this.m_jScale.isSelected());
    arrayOfObject[6] = Formats.CURRENCY.parseValue(this.m_jPriceBuy.getText());
    arrayOfObject[7] = this.pricesell;
    arrayOfObject[8] = this.m_CategoryModel.getSelectedKey();
    arrayOfObject[9] = this.taxcatmodel.getSelectedKey();
    arrayOfObject[10] = this.attmodel.getSelectedKey();
    arrayOfObject[11] = this.m_jImage.getImage();
    arrayOfObject[12] = Formats.CURRENCY.parseValue(this.m_jstockcost.getText());
    arrayOfObject[13] = Formats.DOUBLE.parseValue(this.m_jstockvolume.getText());
    arrayOfObject[14] = Boolean.valueOf(this.m_jInCatalog.isSelected());
    arrayOfObject[15] = Formats.INT.parseValue(this.m_jCatalogOrder.getText());
    arrayOfObject[16] = Formats.BYTEA.parseValue(this.txtAttributes.getText());
    return arrayOfObject;
  }

  public Component getComponent()
  {
    return this;
  }

  private void calculateMargin()
  {
    if (!this.reportlock)
    {
      this.reportlock = true;
      Double localDouble1 = readCurrency(this.m_jPriceBuy.getText());
      Double localDouble2 = (Double)this.pricesell;
      if ((localDouble1 == null) || (localDouble2 == null))
        this.m_jmargin.setText(null);
      else
        this.m_jmargin.setText(Formats.PERCENT.formatValue(new Double(localDouble2.doubleValue() / localDouble1.doubleValue() - 1.0D)));
      this.reportlock = false;
    }
  }

  private void calculatePriceSellTax()
  {
    if (!this.reportlock)
    {
      this.reportlock = true;
      Double localDouble = (Double)this.pricesell;
      if (localDouble == null)
      {
        this.m_jPriceSellTax.setText(null);
      }
      else
      {
        double d = this.taxeslogic.getTaxRate((TaxCategoryInfo)this.taxcatmodel.getSelectedItem(), new Date());
        this.m_jPriceSellTax.setText(Formats.CURRENCY.formatValue(new Double(localDouble.doubleValue() * (1.0D + d))));
      }
      this.reportlock = false;
    }
  }

  private void calculatePriceSellfromMargin()
  {
    if (!this.reportlock)
    {
      this.reportlock = true;
      Double localDouble1 = readCurrency(this.m_jPriceBuy.getText());
      Double localDouble2 = readPercent(this.m_jmargin.getText());
      if ((localDouble2 == null) || (localDouble1 == null))
        setPriceSell(null);
      else
        setPriceSell(new Double(localDouble1.doubleValue() * (1.0D + localDouble2.doubleValue())));
      this.reportlock = false;
    }
  }

  private void calculatePriceSellfromPST()
  {
    if (!this.reportlock)
    {
      this.reportlock = true;
      Double localDouble = readCurrency(this.m_jPriceSellTax.getText());
      if (localDouble == null)
      {
        setPriceSell(null);
      }
      else
      {
        double d = this.taxeslogic.getTaxRate((TaxCategoryInfo)this.taxcatmodel.getSelectedItem(), new Date());
        setPriceSell(new Double(localDouble.doubleValue() / (1.0D + d)));
      }
      this.reportlock = false;
    }
  }

  private void setPriceSell(Object paramObject)
  {
    if (!this.priceselllock)
    {
      this.priceselllock = true;
      this.pricesell = paramObject;
      this.m_jPriceSell.setText(Formats.CURRENCY.formatValue(this.pricesell));
      this.priceselllock = false;
    }
  }

  private static final Double readCurrency(String paramString)
  {
    try
    {
      return (Double)Formats.CURRENCY.parseValue(paramString);
    }
    catch (BasicException localBasicException)
    {
    }
    return null;
  }

  private static final Double readPercent(String paramString)
  {
    try
    {
      return (Double)Formats.PERCENT.parseValue(paramString);
    }
    catch (BasicException localBasicException)
    {
    }
    return null;
  }

  private void initComponents()
  {
    this.jLabel1 = new JLabel();
    this.jLabel2 = new JLabel();
    this.m_jRef = new JTextField();
    this.m_jName = new JTextField();
    this.m_jTitle = new JLabel();
    this.jTabbedPane1 = new JTabbedPane();
    this.jPanel1 = new JPanel();
    this.jLabel6 = new JLabel();
    this.m_jCode = new JTextField();
    this.m_jImage = new JImageEditor();
    this.jLabel3 = new JLabel();
    this.m_jPriceBuy = new JTextField();
    this.jLabel4 = new JLabel();
    this.m_jPriceSell = new JTextField();
    this.jLabel5 = new JLabel();
    this.m_jCategory = new JComboBox();
    this.jLabel7 = new JLabel();
    this.m_jTax = new JComboBox();
    this.m_jmargin = new JTextField();
    this.m_jPriceSellTax = new JTextField();
    this.jLabel16 = new JLabel();
    this.m_jCodetype = new JComboBox();
    this.jLabel13 = new JLabel();
    this.m_jAtt = new JComboBox();
    this.jPanel2 = new JPanel();
    this.jLabel9 = new JLabel();
    this.m_jstockcost = new JTextField();
    this.jLabel10 = new JLabel();
    this.m_jstockvolume = new JTextField();
    this.m_jScale = new JCheckBox();
    this.m_jComment = new JCheckBox();
    this.jLabel18 = new JLabel();
    this.m_jCatalogOrder = new JTextField();
    this.m_jInCatalog = new JCheckBox();
    this.jLabel8 = new JLabel();
    this.jLabel11 = new JLabel();
    this.jLabel12 = new JLabel();
    this.jPanel3 = new JPanel();
    this.jScrollPane1 = new JScrollPane();
    this.txtAttributes = new JTextArea();
    setLayout(null);
    this.jLabel1.setText(AppLocal.getIntString("label.prodref"));
    add(this.jLabel1);
    this.jLabel1.setBounds(10, 50, 80, 15);
    this.jLabel2.setText(AppLocal.getIntString("label.prodname"));
    add(this.jLabel2);
    this.jLabel2.setBounds(180, 50, 70, 15);
    add(this.m_jRef);
    this.m_jRef.setBounds(90, 50, 70, 19);
    add(this.m_jName);
    this.m_jName.setBounds(250, 50, 220, 19);
    this.m_jTitle.setFont(new Font("SansSerif", 3, 18));
    add(this.m_jTitle);
    this.m_jTitle.setBounds(10, 10, 320, 30);
    this.jPanel1.setLayout(null);
    this.jLabel6.setText(AppLocal.getIntString("label.prodbarcode"));
    this.jPanel1.add(this.jLabel6);
    this.jLabel6.setBounds(10, 20, 150, 15);
    this.jPanel1.add(this.m_jCode);
    this.m_jCode.setBounds(160, 20, 170, 19);
    this.jPanel1.add(this.m_jImage);
    this.m_jImage.setBounds(340, 20, 200, 180);
    this.jLabel3.setText(AppLocal.getIntString("label.prodpricebuy"));
    this.jPanel1.add(this.jLabel3);
    this.jLabel3.setBounds(10, 50, 150, 15);
    this.m_jPriceBuy.setHorizontalAlignment(4);
    this.jPanel1.add(this.m_jPriceBuy);
    this.m_jPriceBuy.setBounds(160, 50, 80, 19);
    this.jLabel4.setText(AppLocal.getIntString("label.prodpricesell"));
    this.jPanel1.add(this.jLabel4);
    this.jLabel4.setBounds(10, 80, 150, 15);
    this.m_jPriceSell.setHorizontalAlignment(4);
    this.jPanel1.add(this.m_jPriceSell);
    this.m_jPriceSell.setBounds(160, 80, 80, 19);
    this.jLabel5.setText(AppLocal.getIntString("label.prodcategory"));
    this.jPanel1.add(this.jLabel5);
    this.jLabel5.setBounds(10, 170, 150, 15);
    this.jPanel1.add(this.m_jCategory);
    this.m_jCategory.setBounds(160, 170, 170, 20);
    this.jLabel7.setText(AppLocal.getIntString("label.taxcategory"));
    this.jPanel1.add(this.jLabel7);
    this.jLabel7.setBounds(10, 140, 150, 15);
    this.jPanel1.add(this.m_jTax);
    this.m_jTax.setBounds(160, 140, 170, 20);
    this.m_jmargin.setHorizontalAlignment(4);
    this.jPanel1.add(this.m_jmargin);
    this.m_jmargin.setBounds(250, 80, 80, 19);
    this.m_jPriceSellTax.setHorizontalAlignment(4);
    this.jPanel1.add(this.m_jPriceSellTax);
    this.m_jPriceSellTax.setBounds(160, 110, 80, 19);
    this.jLabel16.setText(AppLocal.getIntString("label.prodpriceselltax"));
    this.jPanel1.add(this.jLabel16);
    this.jLabel16.setBounds(10, 110, 150, 15);
    this.jPanel1.add(this.m_jCodetype);
    this.m_jCodetype.setBounds(250, 40, 80, 20);
    this.jLabel13.setText(AppLocal.getIntString("label.attributes"));
    this.jPanel1.add(this.jLabel13);
    this.jLabel13.setBounds(10, 200, 150, 15);
    this.jPanel1.add(this.m_jAtt);
    this.m_jAtt.setBounds(160, 200, 170, 20);
    this.jTabbedPane1.addTab(AppLocal.getIntString("label.prodgeneral"), this.jPanel1);
    this.jPanel2.setLayout(null);
    this.jLabel9.setText(AppLocal.getIntString("label.prodstockcost"));
    this.jPanel2.add(this.jLabel9);
    this.jLabel9.setBounds(10, 20, 150, 15);
    this.m_jstockcost.setHorizontalAlignment(4);
    this.jPanel2.add(this.m_jstockcost);
    this.m_jstockcost.setBounds(160, 20, 80, 19);
    this.jLabel10.setText(AppLocal.getIntString("label.prodstockvol"));
    this.jPanel2.add(this.jLabel10);
    this.jLabel10.setBounds(10, 50, 150, 15);
    this.m_jstockvolume.setHorizontalAlignment(4);
    this.jPanel2.add(this.m_jstockvolume);
    this.m_jstockvolume.setBounds(160, 50, 80, 19);
    this.jPanel2.add(this.m_jScale);
    this.m_jScale.setBounds(160, 140, 80, 21);
    this.jPanel2.add(this.m_jComment);
    this.m_jComment.setBounds(160, 110, 80, 21);
    this.jLabel18.setText(AppLocal.getIntString("label.prodorder"));
    this.jPanel2.add(this.jLabel18);
    this.jLabel18.setBounds(250, 80, 60, 15);
    this.m_jCatalogOrder.setHorizontalAlignment(4);
    this.jPanel2.add(this.m_jCatalogOrder);
    this.m_jCatalogOrder.setBounds(310, 80, 80, 19);
    this.m_jInCatalog.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        ProductsEditor.this.m_jInCatalogActionPerformed(paramActionEvent);
      }
    });
    this.jPanel2.add(this.m_jInCatalog);
    this.m_jInCatalog.setBounds(160, 80, 50, 21);
    this.jLabel8.setText(AppLocal.getIntString("label.prodincatalog"));
    this.jPanel2.add(this.jLabel8);
    this.jLabel8.setBounds(10, 80, 150, 15);
    this.jLabel11.setText(AppLocal.getIntString("label.prodaux"));
    this.jPanel2.add(this.jLabel11);
    this.jLabel11.setBounds(10, 110, 150, 15);
    this.jLabel12.setText(AppLocal.getIntString("label.prodscale"));
    this.jPanel2.add(this.jLabel12);
    this.jLabel12.setBounds(10, 140, 150, 15);
    this.jTabbedPane1.addTab(AppLocal.getIntString("label.prodstock"), this.jPanel2);
    this.jPanel3.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.jPanel3.setLayout(new BorderLayout());
    this.txtAttributes.setFont(new Font("DialogInput", 0, 12));
    this.jScrollPane1.setViewportView(this.txtAttributes);
    this.jPanel3.add(this.jScrollPane1, "Center");
    this.jTabbedPane1.addTab(AppLocal.getIntString("label.properties"), this.jPanel3);
    add(this.jTabbedPane1);
    this.jTabbedPane1.setBounds(10, 90, 560, 280);
  }

  private void m_jInCatalogActionPerformed(ActionEvent paramActionEvent)
  {
    if (this.m_jInCatalog.isSelected())
    {
      this.m_jCatalogOrder.setEnabled(true);
    }
    else
    {
      this.m_jCatalogOrder.setEnabled(false);
      this.m_jCatalogOrder.setText(null);
    }
  }

  private class MarginManager
    implements DocumentListener
  {
    private MarginManager()
    {
    }

    public void changedUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void insertUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void removeUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }
  }

  private class PriceTaxManager
    implements DocumentListener
  {
    private PriceTaxManager()
    {
    }

    public void changedUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromPST();
      ProductsEditor.this.calculateMargin();
    }

    public void insertUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromPST();
      ProductsEditor.this.calculateMargin();
    }

    public void removeUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculatePriceSellfromPST();
      ProductsEditor.this.calculateMargin();
    }
  }

  public class FieldsManager
    implements DocumentListener, ActionListener
  {
    private FieldsManager()
    {
    }

    public void changedUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void insertUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void removeUpdate(DocumentEvent paramDocumentEvent)
    {
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void actionPerformed(ActionEvent paramActionEvent)
    {
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }
  }

  private class PriceSellManager
    implements DocumentListener
  {
    private PriceSellManager()
    {
    }

    public void changedUpdate(DocumentEvent paramDocumentEvent)
    {
      if (!ProductsEditor.this.priceselllock)
      {
    	  //ati
//        ProductsEditor.access$402(ProductsEditor.this, true);
//        ProductsEditor.access$502(ProductsEditor.this, ProductsEditor.access$700(ProductsEditor.this.m_jPriceSell.getText()));
//        ProductsEditor.access$402(ProductsEditor.this, false);
      }
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void insertUpdate(DocumentEvent paramDocumentEvent)
    {
      if (!ProductsEditor.this.priceselllock)
      {
    	  //ati
//        ProductsEditor.access$402(ProductsEditor.this, true);
//        ProductsEditor.access$502(ProductsEditor.this, ProductsEditor.access$700(ProductsEditor.this.m_jPriceSell.getText()));
//        ProductsEditor.access$402(ProductsEditor.this, false);
      }
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }

    public void removeUpdate(DocumentEvent paramDocumentEvent)
    {
      if (!ProductsEditor.this.priceselllock)
      {
//        ProductsEditor.access$402(ProductsEditor.this, true);
//        ProductsEditor.access$502(ProductsEditor.this, ProductsEditor.access$700(ProductsEditor.this.m_jPriceSell.getText()));
//        ProductsEditor.access$402(ProductsEditor.this, false);
      }
      ProductsEditor.this.calculateMargin();
      ProductsEditor.this.calculatePriceSellTax();
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.ProductsEditor
 * JD-Core Version:    0.6.0
 */